<?php
class NewsModel extends Model
{
    function __construct()
    {
        $this->loadTable('post');
    }

    public function getNews($id)
    {
        return $this->tables['post']->get(array('id' => $id));
    }

    public function getLastestAlbum()
    {
        $this->loadTable('album');
        $this->loadTable('item');
        $rs = $this->tables['album']->get(NULL, array('order' => array('id' => 'DESC')));
        $row = $rs->getRow(0);
        $rs2 = $this->tables['item']->get(array('album_id' => $row->id));
        return $rs2;
    }

    public function getLastestNews($offset = 0)
    {
        $this->loadTable('post');
        $rs = $this->tables['post']->get(array('category_id' => array('IS NOT', NULL)), array('order' => array('p_date' => 'DESC'), 'limit' => 5, 'offset' => $offset * 5));
        return $rs;
    }
}